package com.zzh.arc;


import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import com.zzh.arc.menu.ArcMenu;
import com.zzh.arc.menu.RayMenu;
import com.zzh.dialog.R;
import com.zzh.dialog.databinding.ActArcMenuBinding;

import androidx.annotation.Nullable;

/**
 * Created by zzh on 2024/8/23.
 *
 * @date: 2024/8/23 10:44
 * @email: zzh_hz@126.com
 * @author: zzh
 * @description: com.zzh.arc
 */
public class ArcMenuActivity extends Activity {

    ActArcMenuBinding bind;
    private static final int[] ITEM_DRAWABLES = {R.drawable.composer_camera, R.drawable.composer_music,
            R.drawable.composer_place/*, R.drawable.composer_sleep, R.drawable.composer_thought,
            R.drawable.composer_with*/};

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        bind = ActArcMenuBinding.inflate(getLayoutInflater());
        setContentView(bind.getRoot());
        initArcMenu(bind.arcMenu, ITEM_DRAWABLES);
        initArcMenu(bind.arcMenu2, ITEM_DRAWABLES);

        RayMenu rayMenu = findViewById(R.id.ray_menu);
        final int itemCount = ITEM_DRAWABLES.length;
        for (int i = 0; i < itemCount; i++) {
            ImageView item = new ImageView(this);
            item.setImageResource(ITEM_DRAWABLES[i]);

            final int position = i;
            rayMenu.addItem(item, new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    Toast.makeText(ArcMenuActivity.this, "position:" + position, Toast.LENGTH_SHORT).show();
                }
            });// Add a menu item
        }

    }

    private void initArcMenu(ArcMenu menu, int[] itemDrawables) {
        final int itemCount = itemDrawables.length;
        for (int i = 0; i < itemCount; i++) {
            ImageView item = new ImageView(this);
            item.setImageResource(itemDrawables[i]);

            final int position = i;
            menu.addItem(item, new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    Toast.makeText(ArcMenuActivity.this, "position:" + position, Toast.LENGTH_SHORT).show();
                }
            });
        }
    }
}
